﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Auditing;
using Volo.Abp.Domain.Entities;
using Volo.Abp.Domain.Entities.Auditing;
using XfTech.SmartTms.ValueObjects;

namespace XfTech.SmartTms.Entities
{
    /// <summary>
    /// 车辆聚合根实体类（继承基类带审计字段的AuditedAggregateRoot，主键类型为Guid）
    /// </summary>
    public class Vehicle : AuditedAggregateRoot<Guid>, IHasDeletionTime
    {
        /// <summary>
        /// 品牌型号
        /// </summary>
        public string Brand { get; protected  set; }

        /// <summary>
        /// 车牌号
        /// </summary>
        public string LicensePlate { get; protected set; }

        /// <summary>
        /// 司机姓名
        /// </summary>
        public string Driver { get; protected set; }

        /// <summary>
        /// 所属公司
        /// </summary>
        public string Company { get; protected set; }

        /// <summary>
        /// 车型大小（值对象）
        /// </summary>
        public VehicleSize Size { get; protected set; }

        /// <summary>
        /// 车辆颜色
        /// </summary>
        public string Color { get; protected set; }

        /// <summary>
        /// 购置日期
        /// </summary>
        public DateTime BuyDate { get; protected set; }

        /// <summary>
        /// 营运证号
        /// </summary>
        public string VehicleNo { get; protected set; }

        /// <summary>
        /// 保险到期日期
        /// </summary>
        public DateTime InsuranceDate { get; protected set; }

        /// <summary>
        /// 年检到期日期
        /// </summary>
        public DateTime AnnualCheckDate { get; protected set; }

        /// <summary>
        /// 保养公里数设置
        /// </summary>
        public int Maintenance { get; protected set; }

        /// <summary>
        /// 车辆照片
        /// </summary>
        public string VehiclePhoto { get; protected set; }

        /// <summary>
        /// 保险卡照片
        /// </summary>
        public string InsurancePhoto { get; protected set; }


        public DateTime? DeletionTime { get;  set; }

        public bool IsDeleted { get;  set; }

        //默认构造函数（必须的，EFCore反序列化用的）
        protected Vehicle()
        {
        }

        /// <summary>
        /// 构造方法
        /// </summary>
        /// <param name="id"></param>
        public Vehicle(Guid id, string brand, string licensePlate, string driver, string company, VehicleSize size,  string color, DateTime buyDate, string vehicleNo, DateTime insuranceDate, DateTime annualCheckDate,
            int maintenance,string vehiclePhoto, string insurancePhoto, DateTime creationTime, Guid? creatorId
            )
        {
            Id = id;
            Brand = brand;
            LicensePlate = licensePlate;
            Driver = driver;
            Company = company;
            Size = size;
            Color = color;
            BuyDate = buyDate;
            VehicleNo = vehicleNo;
            InsuranceDate = insuranceDate;
            AnnualCheckDate = annualCheckDate;
            Maintenance = maintenance;
            VehiclePhoto = vehiclePhoto;
            InsurancePhoto = insurancePhoto;
            CreationTime = creationTime;  //创建时间
            CreatorId = creatorId;        //创建者
        }

        /// <summary>
        /// 软删除
        /// </summary>
        public void SoftDelete()
        {
            IsDeleted = true;
            DeletionTime = DateTime.Now;
        }
    }
}
